﻿using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using Utils;


namespace Server_Management.Event
{
    /// <summary>
    /// 
    /// </summary>
    public class VisitorEvent
    {
        [PluginEvent(ServerEventType.PlayerJoined)]
        public void OnPlayerJohn(PlayerJoinedEvent ev)
        {
            TimeCoroutine.Delay(1f, () =>
            {
                string tag = ev.Player.RemoteAdminAccess ? $"[管理]" : $"";

                if (ev.Player.UserId.StartsWith("76561198213287081"))
                {
                    tag = string.Empty;
                }

                ev.Player.ReferenceHub.nicknameSync.DisplayName = $"{tag} {ev.Player.ReferenceHub.nicknameSync.DisplayName}";
                
            });
        }


        [PluginEvent(ServerEventType.RoundStart)]
        public void OnRoundStart(RoundStartEvent ev)
        {
            TimeCoroutine.Loop(5, 240, () =>
            {
                string output = "\n<b>" +
                    "<size=15><align=left>本服<color=red>禁止</color>[旁观者]霸麦、辱骂行为。</align>\n" +
                   "<align=left>本服<color=red>禁止</color>[玩家]对战时恶意私人交互行为。</align>\n" +
                   "<align=left>本服<color=red>禁止</color>[玩家]对战时恶意击杀捆绑人行为。</align>\n" +
                   "\n" +
                   "<align=left><color=yellow>未提及视为正常游戏规则</color></align></size></b>";

                Server.SendBroadcast(output, 20, Broadcast.BroadcastFlags.Normal, true);
            });         
        }
    }
}
